<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>4-改变函数内部this指向</title>
</head>
<body>
    <script type="text/javascript">
        /**
         * call方法 
         * 1.可以调用函数
         * 2.改变this指向
         * 3.call()参数1对象 ，后面依次根据定义的函数进行传参
         */
        function setData(x,y){
            console.log(x);
            console.log(y);
            console.log(x+y);
            console.log(this);//Window
        }
        //setData();
        setData.call(Window,1,2);

        var Mobile = {
            brand:'华为',
            price:2999
        };
        //此时this指向Object { brand: "华为", price: 2999 }
        setData.call(Mobile,10,20);



    </script>
</body>
</html>